package org.systemsbiology.addama.sequencing.controllers;

import org.apache.commons.httpclient.methods.multipart.PartSource;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author hrovira
 */
public class MultipartFilePartSource implements PartSource {
    private final MultipartFile multipartFile;

    public MultipartFilePartSource(MultipartFile multipartFile) {
        this.multipartFile = multipartFile;
    }

    public long getLength() {
        return this.multipartFile.getSize();
    }

    /*public String getFileName() {
        return this.multipartFile.getName();
    }*/

    public String getFileName() {
        return this.multipartFile.getOriginalFilename();
    }


    public InputStream createInputStream() throws IOException {
        return this.multipartFile.getInputStream();
    }
}
